<?php $this->load->view('header') ?>

<div id="content">
<div class="column full fl">
		
		<div class="box">
		<div class="box-header">Daftar Pembayaran Hari Ini</div>
		<div class="box-content box-table">
		<br />
		
        	<?php if (isset($errorMessage)) : ?>
            	<div class="notification <?php echo ((isset($isSuccess) && $isSuccess) ? 'success' : 'error');?>"><?php echo $errorMessage; ?></div>
	        <?php endif; ?>    	
	        <br />

			<table class="tablebox">
	        	<tr class='even'>
	        		<td width='100'><b>Status Pasien</b></td>
	        		<td width='10'> : </td>
	        		<td>
	        			<select name='status' id='status' class='modalLoader'>
							<option value='all'>Semua Status</option>	       
					        <?php if($listStatus) foreach($listStatus as $status):?>
					        	<option value='<?php echo $status;?>' <?php echo get_data($uri_to_assoc,'status') == $status ? 'selected="selected"' : '';?>>
					        		<?php echo $status;?>
					        	</option>	 
					        <?php endforeach;?>
				        </select>
					</td>
	        	</tr>
			</table>
			<br />

            <table class="tablebox">
            <thead class="table-header" style="border-top:1px solid #ccc;border-bottom:1px solid #ccc">
                <tr>
                	<th width="10">No</th>
                    <th>Kode RM</th>
                    <th>Nama</th>
                    <th>Jenkel</th>
                    <th>Usia</th>
                    <th>Status</th>                         
                    <th>Biaya</th>
                    <th width="200">Action</th>
                </tr>
            </thead>
            <tbody>
            	<?php $no = get_data($uri_to_assoc,'page') + 1;?>
            	<?php $totalPayment = 0;?>
            	
                <?php if ($dataView) foreach($dataView as $key=>$row) : ?>
                <?php $class = $no % 2 == 0 ? 'even' : 'odd' ?>
                <tr class=<?php echo $class?>>
                	<td><?php echo $no?></td>
                    <td><?php echo get_data($row,'rmKode');?></td>
                    <td><?php echo get_data($row,'pasienNama')?></td>
                    <td><?php echo get_data($row,'pasienJenKel')?></td>
                    <td><?php echo getUsia( get_data($row,'pasienTglLahir') )?></td>
                    <td>
                    	<?php if( get_data($row,'rmStatus') == 'Tunggu' ):?>
                    		<?php echo '<span class="icon_text edit"></span>'.get_data($row,'rmStatus');?>
                    	<?php elseif( get_data($row,'rmStatus') == 'Selesai' ):?>
                    		<?php echo '<span class="icon_text accept"></span>'.get_data($row,'rmStatus');?>
                    	<?php endif?>
                    </td>
                    <td>
                    	<?php if( !empty($row['rmTotalBiaya']) ):?>
                    		Rp. <span style="float:right;"><?php echo number_format( get_data($row,'rmTotalBiaya') )?></span>
                    	<?php else:?>
                    		- 
                    	<?php endif;?>
                    </td>
                    <td>
                    	<?php echo anchor('klinik/registrasi/proses/from/paymentToday/id/' . $row['rmId'], '<span class="icon_text save"></span>Payment', 'class="button white"');?>
                    	
                    	<?php if( !empty($row['rmStatus']) && $row['rmStatus'] == 'Selesai' ):?>
                        	<?php echo anchor('klinik/registrasi/preview/from/paymentToday/id/' . $row['rmId'], 'cetak', 'class="button white"');?>
                    	<?php endif;?>
                    </td>
                </tr>
                <?php $totalPayment = $totalPayment + get_data($row,'rmTotalBiaya');?>
                <?php $no++?>
                <?php endforeach;?>
            </tbody>
            </tfoot>
                <!-- Total Payment -->
                <?php if($totalPayment > 0):?>
	                <?php $class = $no % 2 == 0 ? 'even' : 'odd' ?>
	                <tr class=<?php echo $class?>>
	                	<td></td><td></td><td></td>
	                	<td></td><td></td>
	                	<td><b>TOTAL BIAYA</b></td>
	                	<td style='font-weight:bold;font-size:14px;'>
	                		Rp. <span style="float:right;"><?php echo number_format($totalPayment)?></span>
	                	</td>
	                	
	                	<?php if( isAccess ( 'kasir', 'payment', 'printtoday') ):?>
	                	<td>
	            			<?php echo $dataView && ($totalPayment > 0)  ? anchor('klinik/payment/printToday/', '<span class="icon_text pdf"></span>Export Data', 'class="button white"') : '';?>    
	            		</td>
	            		<?php endif;?>
	            		 
	                </tr>
	            <?php endif;?>
	            
            </tfoot>
            </table>

		</div>
		</div>
	
	</div>
 
<script type="text/javascript">
<!--
jQuery(document).ready(function($){
	statusChange = function() {
        if (this.value)
            document.location.href = site_url('klinik/payment/today/status/' + $('#status').val() );
    };
    $('#status').bind('change',statusChange);
});
//-->
</script> 
<?php $this->load->view('footer') ?>
